package com.rslai.base.tool.servertest.command;

import com.rslai.base.tool.servertest.context.Context;
import com.rslai.base.tool.servertest.model.KeyValueStore;
import com.rslai.base.tool.servertest.response.Response;
import com.rslai.base.tool.servertest.util.ParameterUtils;

import java.util.List;

public abstract class ParameterizedCommand extends StepCommand {
    protected List<KeyValueStore> params;

    public ParameterizedCommand(List<KeyValueStore> params) {
        this.params = params;
    }

    public Response doExecute(Response preResult, Context context) throws Throwable {
        List processedParameters = ParameterUtils.prepareParameters(this.params, preResult, context);
        return doExecuteInternal(preResult, processedParameters, context);
    }

    protected abstract Response doExecuteInternal(Response paramResponse, List<KeyValueStore> paramList, Context paramContext) throws Throwable;

    public List<KeyValueStore> getParams() {
        return this.params;
    }
}
